package com.yixun.qfbao.model.enums;

/**
 * 
 * @author zilong.liu
 * @date 2020-08-09
 */
public enum RoomNumberEnum {

	ROOM_1(1, "一室", 0, 2),
	ROOM_2(2, "二室", 1, 3),
	ROOM_3(3, "三室", 2 ,4),
	ROOM_4(4, "四室", 3, 5),
	ROOM_5_MAX(5, "五室及以上", 4, Integer.MAX_VALUE);
	
	private int no;
	private String des;
	
	private int min;
	private int max;
	
	RoomNumberEnum(int no, String desc, int min, int max) {
		this.no = no;
		this.des = desc;
		this.min = min;
		this.max = max;
	}
	
	/**
	 * 根据no获取最小值
	 * 	没找到则返回-1
	 * @param no
	 * @return
	 */
	public static int getMinByNo(Integer no) {
		if(no == null) {
			return -1;
		}
		for (RoomNumberEnum roomNumberEnum : values()) {
			if(roomNumberEnum.getNo() == no) {
				return roomNumberEnum.getMin();
			}
		}
		return -1;
	}
	
	/**
	 * 根据no获取最大值
	 * 	没找到则返回0
	 * @param no
	 * @return
	 */
	public static int getMaxByNo(Integer no) {
		if(no == null) {
			return -1;
		}
		for (RoomNumberEnum roomNumberEnum : values()) {
			if(roomNumberEnum.getNo() == no) {
				return roomNumberEnum.getMax();
			}
		}
		return -1;
	}

	public int getNo() {
		return no;
	}

	public String getDes() {
		return des;
	}

	public int getMin() {
		return min;
	}

	public int getMax() {
		return max;
	}

}
